<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt'%>

<script>	
	function table_sort() {
		if ($("#tbl_stuffs").find("tr").size() > 1) {
			$("#tbl_stuffs").tablesorter({ 
				// set forced sort on the fourth column and i decending order. 
				// sortList: [[4,1]] 
			});
		}
	}
</script>

<form id="pagerForm" method="post" action="app/project/base.do?action=dialogProjectMaterialRepository">
	<input type="hidden" name="pageNum" value="${pagingBean ne null ? pagingBean.currentPage : 1}" />
	<input type="hidden" name="numPerPage" value="${pagingBean ne null ? pagingBean.pageSize : 20}" />
</form>

<!-- Body -->
<div class="pageContent">
	<table class="table" width="100%" layoutH="55" id="tbl_stuffs" beforeRender="table_sort();">
		<thead>
			<tr>
				<th align="center">序号</th>
				<th align="center">材料名称</th>
				<th align="center">材料性质</th>
				<th align="center">提交人</th>
				<th align="center">提交时间</th>
				<th align="center">下载</th>
			</tr>
		</thead>
		<tbody>
			<logic:present name="datagrid">
				<logic:iterate name="datagrid" id="entity" indexId="idx">
					<tr ${idx % 2 == 1 ? 'style="background-color: #F5F5F5"' : ''}>
						<td>${idx+1}</td>
						<td style="text-align: left">${entity.materialName}</td>
						<td style="background-color: ${entity.materialType eq 1 ? '#D9896A' : (entity.materialType eq 0 ? '#3FA156' : '#CCC')}">${entity.materialType eq 1 ? '* 必须提交' : (entity.materialType eq 0 ? '建议提交' : '补充提交')}</td>
						<td>
							<c:choose>
								<c:when test="${entity.latestUploadMeta ne null}">${entity.latestUploadMeta.poster ne null ? entity.latestUploadMeta.poster.username : '---'}</c:when>
								<c:otherwise>---</c:otherwise>
							</c:choose>
						</td>
						<td>
							<c:choose>
								<c:when test="${entity.latestUploadMeta ne null}"><fmt:formatDate value="${entity.latestUploadMeta.creationTime}" type="date" pattern="yyyy-MM-dd HH:mm:ss"/></c:when>
								<c:otherwise>---</c:otherwise>
							</c:choose>
						</td>
						<td>
							<a href="file-download?path=${entity.latestUploadMeta.attachment.filePath}&filename=${entity.latestUploadMeta.attachment.fileName}" target="_blank" class="oplink">下载</a>
						</td>
					</tr>
				</logic:iterate>
			</logic:present>
		</tbody>
	</table>
</div>

<div class="formBar">
	<ul>
		<li>
			<div class="button"><div class="buttonContent"><button type="button" class="close">关闭</button></div></div>
		</li>
	</ul>
</div>